package com.main.usermanagement.domain.user.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.main.usermanagement.domain.user.aggregate.User;
import com.main.usermanagement.domain.user.repository.mapper.UserMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRepository extends ServiceImpl<UserMapper, User> {
    public List<User> findByPhone(String phone) {
        return baseMapper.findByPhone(phone);
    }

    public boolean existsByTransactionId(String transactionId) {
        return baseMapper.existsByTransactionId(transactionId);
    }

    public Page<User> getList(Page<User> page) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        queryWrapper.orderByAsc("id");
        return baseMapper.selectPage(page,null);
    }
}
